<?php namespace Admin\Model;
use Hdphp\Model\Model;
class Manager extends Model{
	protected $table = 'manager';
	protected $validate = array(
		array('name','required','用户名不能为空',3,3),
		array('password','required','密码不能为空',3,3)
		);
	public function Vlogin($name,$password){
		if(!$this->create()) return false;
		$oldData = $this->where("name='{$name}'")->find();
		if(!$oldData){
			$this->error="用户名{$name}不存在";
		}
		$password = $this->encrypt($name,$password);
		// sp($password);die;
		if($password != $oldData['password']){
			$this->error="密码不正确";
			return false;
		}
		$_SESSION['name'] = $name;
		$_SESSION['id'] = $oldData['id'];
		return true;
	}
	//加密
	public function encrypt($name,$password){      //加密
		return md5(md5($name).md5($password).'xiaoming');
	}
}
?>